package com.company;

/**
 * Created by phazel on 12/04/14.
 */
public class Diamonds {

    public static void main(String[] args) {

        Diamonds t = new Diamonds();

        t.print();
    }

    private void print()
    {
        System.out.println(exerciseFive( 4 ));
        System.out.println(exerciseSix( 3 ));
        System.out.println(exerciseSeven( 5 ));
    }

    public String exerciseFive( int num )
    {
        String output = "";
        int spaces = num-1;
        for(int line = 1; line <= num; line++)
        {
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            for(int i = 0; i < (line*2)-1; i++)
            {
                output += "*";
            }
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            output +="\n";
            spaces -= 1;
        }
        return output;
    }

    public String exerciseSix( int num )
    {
        String output = "";
        int spaces = num-1;
        for(int line = 1; line <= num; line++)
        {
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            for(int i = 0; i < (line*2)-1; i++)
            {
                output += "*";
            }
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            output +="\n";
            spaces -= 1;
        }
        spaces = 1;
        for(int line = num-1; line > 0; line--)
        {
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            for(int i = 0; i < (line*2)-1; i++)
            {
                output += "*";
            }
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            output += "\n";
            spaces++;
        }
        return output;
    }

    public String exerciseSeven( int num )
    {
        String output = "";
        int spaces = num-1;
        for(int line = 1; line < num; line++)
        {
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            for(int i = 0; i < (line*2)-1; i++)
            {
                output += "*";
            }
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            output +="\n";
            spaces -= 1;
        }
        output += "Courtney\n";
        spaces = 1;
        for(int line = num-1; line > 0; line--)
        {
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            for(int i = 0; i < (line*2)-1; i++)
            {
                output += "*";
            }
            for(int i = 0; i < spaces; i++)
            {
                output += " ";
            }
            output += "\n";
            spaces++;
        }
        return output;
    }
}
